package com.scuthnweb.action.picwallmodule;

import java.util.Iterator;

import com.opensymphony.xwork2.ActionSupport;
import com.scuthnweb.domain.Album;
import com.scuthnweb.domain.Album_pic;
import com.scuthnweb.service.PicwallModule;

public class CheckAlbumPicAction extends ActionSupport{
	private Integer aid;
	private Integer apid;
	
	private PicwallModule picwallModule;
    
	private Album result;
    private String url;
    
    public String execute(){
		this.result = this.picwallModule.checkAlbum(aid);
		if(this.result==null)
			return ERROR;
		Iterator itr = this.result.getAlbum_pics().iterator();
		while(itr.hasNext()){
			Album_pic c = (Album_pic)itr.next();
			if(c.getId().intValue()==apid.intValue()){
				this.url = c.getUrl();
				break;
			}
		}
		if(this.url==null)
			return ERROR;
		else{
			return SUCCESS;
		}
    }
    
    
	public PicwallModule getPicwallModule() {
		return picwallModule;
	}

	public void setPicwallModule(PicwallModule picwallModule) {
		this.picwallModule = picwallModule;
	}

	public Integer getAid() {
		return aid;
	}

	public void setAid(Integer aid) {
		this.aid = aid;
	}

	public Integer getApid() {
		return apid;
	}

	public void setApid(Integer apid) {
		this.apid = apid;
	}

	public Album getResult() {
		return result;
	}

	public void setResult(Album result) {
		this.result = result;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

}
